package controller.login;


import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author HTTHANH
 */
@FacesValidator("nameValidator")
public class nameValidator implements Validator {

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        String username = value.toString();

        

        // Let required="true" do its job.
        if (username == null || username.isEmpty()) {
            return;
        }

        if (!CheckTaiKhoan.checkusername(username) ) {
            throw new ValidatorException(new FacesMessage(
                    "username khong dung."));
        }

    }
}
